package test00.lx06;

import test00.lx04.t01.Student;

import java.util.Optional;

/**
 * @author ZQX
 * @date 2025-04-07
 */
public class MainTest01 {
    public static void main(String[] args) {
        Student stu = new Student(null, 18);
        Optional<Student> optional = Optional.of(stu);

        // R apply(T t);
        // String username = optional.map(s -> {
        //     String name = s.getName();
        //     return name != null ? name.toLowerCase() : null;
        // }).orElse("匿名");

        String username = optional
                .map(Student::getName)
                .map(String::toLowerCase)
                .orElse("匿名");

        System.out.println(username);

    }
}
